package com.happyclub.lcy.dao;


import com.happyclub.pojo.TbUserTeamMap;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface IUserTeam extends JpaRepository<TbUserTeamMap,String> {

    //创建用户队伍中间表
    //加入驴友队，先根据队伍id查到队伍 在往用户队伍中间表，用户角色表里插值
    @Modifying
    @Query(value = "insert into TB_USER_TEAM_MAP(USER_ID,TEAM_ID,UPDATE_TIME,CREATE_TIME) VALUES(?1,?2,?3,?4)",nativeQuery = true)
    int insertTeamUserMap(String userId, String teamId, String updateTime, String createTime);


    //判断该用户是否已加入该驴友队
    List<TbUserTeamMap> findTbUserTeamMapByUserIdAndTeamId(String userId, String teamId);


    //退出驴友队
    @Modifying
    @Query(value = "delete from TB_USER_TEAM_MAP where USER_ID =?1",nativeQuery = true)
    int delUserRoleMapByUserId(String userId);

}
